import { request } from '../utils/request'
const getUserChannelAPI = () => {
  return request({
    url: '/v1_0/user/channels'
  })
}
const getArticlesListAPI = ({ id, timestamp }) => {
  return request({
    url: '/v1_0/articles',
    params: {
      channel_id: id,
      timestamp: timestamp || +new Date() + ''
    }
  })
}
// 不感兴趣
const postDislikes = (id) => {
  return request({
    method: 'POST',
    url: '/v1_0/article/dislikes',
    data: {
      target: id
    }
  })
}
// 举报
const PostReports = ({ target, type, remark }) => {
  return request({
    method: 'POST',
    url: '/v1_0/article/reports',
    data: {
      target, type, remark
    }
  })
}
// 获取所有
const Getchannels = () => {
  return request({
    url: '/v1_0/channels'
  })
}
// 更新
const PUTchannels = ({ channels }) => {
  return request({
    method: 'PUT',
    url: '/v1_0/user/channels',
    data: {
      channels
    }
  })
}
// 搜索功能
const GETsuggestion = (q) => {
  return request({
    url: '/v1_0/suggestion',
    params: {
      q
    }
  })
}
// 搜索跳转
const searchResultListAPI = ({ q, page = 1 }) => {
  return request({
    url: '/v1_0/search',
    params: {
      q,
      page
    }
  })
}
export { getUserChannelAPI, getArticlesListAPI, postDislikes, PostReports, Getchannels, PUTchannels, GETsuggestion, searchResultListAPI }
